logo头像
Snippet 博客主题

android Flutter 6.获取数据-post

本文于370天之前发表,文中内容可能已经过时。

android Flutter 6.获取数据-post

1
2
3
4
5
6
7
8
9
10
11
12
13
14
static void post(String url, Function callback, { String params, Function errorCallback}) async {
Map<String, String> headers = new Map();
headers['Content-Type'] = 'application/json';
try {
http.Response res = await http.post(url,headers : headers, body: params);
if (callback != null) {
callback(res.body);
}
} catch (e) {
if (errorCallback != null) {
errorCallback(e);
}
}
}

发送请求

1
2
3
4
5
6
7
8
9
10
11
String jsonParams = json.encode({"appCode":"snap","baiduChanelToken":""});
NetUtils.post(
Api.Login,
(data) {
print('data is ${ data }');
//
},
params: jsonParams,
errorCallback: (e) {
print(' errorCallback ' + e);
});
支付宝打赏 微信打赏

打赏